$(function(){
	bindCardQuery();
});


function bindCardQuery(){
	$('#button').unbind('click');
	$('#button').bind('click',function(){
		var payeeIdReg = /^[0-9]+$/;
		var merKeyReg = /^[A-Za-z0-9]+$/;
		var certNoReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		var payeeId = $('#payeeId').val();
		var certNo = $('#certNo').val();
		var orderNo = $('#orderNo').val();
		var merKey = $('#merKey').val();
		if(!payeeIdReg.test(payeeId)){
			alertMsg('请输入正确的商户号!');
			return;
		}
		if(!certNoReg.test(certNo)){
			alertMsg('请输入正确的身份证号码!');
		}
		if(!payeeIdReg.test(orderNo)){
			alertMsg('请输入正确的订单号!');
			return;
		}
		if(!merKeyReg.test(merKey)){
			alertMsg('请输入正确的merKey!');
			return;
		}
		var params = {
				payeeId:payeeId,
				certNo:certNo,
				orderNo:orderNo,
				merKey:merKey
		};
		var reqUrl = '../bind/bindCardQuery';
		$.ajax({
			url: reqUrl,
			type: 'POST',
			//同步执行
			async:false,
			data: params,
			dataType: 'json',
			success: function(data) {
				$('#result').text(JSON.stringify(data));
			},
			error: function(data) {
				alertMsg("未知错误");
			}
		});
		
	});
}

function alertMsg(msg){
	var params = {
	    container : {
		    content :msg
		  },
		autoClose : 1500
	};
	easyDialog.open(params);
}